var db = require( '../db/db' );
var redisUtils = require( '../utils/redis_utils' );

const tableName = 'core.security_token';

exports.getByKey = async function ( key ) {
    if ( !key ) {
        return { code: 1 };
    }

    var sql = `select * from ${ tableName } where key=$1 and expire_at>=now() limit 1`

    var params = [ key ];

    var result = await db.runSql( sql, params );
    return result;
}
